package com.bw.shinelon.yuekaoa;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.ImageView;

public class MainActivity extends AppCompatActivity {

    private ImageView imageView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        imageView = (ImageView) findViewById(R.id.iv_jq);
        SharedPreferences sp = getSharedPreferences("db", MODE_PRIVATE);
        boolean flag = sp.getBoolean("flag", false);
        donghua();
        sp.edit().putBoolean("flag",true).commit();
        if (flag){
            startActivity(new Intent(MainActivity.this,Main2Activity.class));
        }

    }
    private void donghua(){
        TranslateAnimation translateAnimation=new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.5f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f);
        translateAnimation.setDuration(2000);
        translateAnimation.setFillAfter(true);
        //对当前的图片设置动画
        imageView.setAnimation(translateAnimation);
        translateAnimation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                startActivity(new Intent(MainActivity.this,Main2Activity.class));

            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
    }
}
